package singleStep;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.io.File;
import java.util.List;

import static utils.JsonMap.splitNode;

public class JsonNodeSplitter {

    public static void main(String[] args) throws Exception {

        String inputFile = "D:\\code\\hdfork\\archguard\\server\\dependencies\\codeCrop.json";
        String outputFile = "D:\\code\\hdfork\\archguard\\server\\dependencies\\codeCropSplit.json";

        ObjectMapper mapper = new ObjectMapper();

        // 解析为可修改的ObjectNode
        JsonNode root = mapper.readTree(new File(inputFile));

        // 执行节点拆分gua
        List<JsonNode> article = splitNode(root, "Article");

        for (JsonNode node : article){
            mapper.writerWithDefaultPrettyPrinter().writeValue(new File(outputFile), node);

        }
        // 输出结果
    }
}